/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package HGR.Learning;

import HGR.Listener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.util.ArrayList;
import java.util.Collections;

/**
 *
 * @author Warrior3D
 */
public class Test extends javax.swing.JFrame{
    
    private Listener Hilo;

    public int[] nums = new int[5];

    public static void main(String argv[]) //throws FileNotFoundException, IOException, Throwable
    {
        /*ArrayList<String> fileHist = new ArrayList<String>();
        ListDir("Histograms", fileHist, ".hist");
        Collections.shuffle(fileHist);


        int u=0;
        for(int i = 0; i<fileHist.size(); i++)
        {            
            if(u < 10)
            {
                writeShuffle(fileHist.get(i), u+1);
            }else{                
                u=0;
                writeShuffle(fileHist.get(i), u+1);
            }
            u++;
        }

        System.out.print("_");*/

        //Hilo = new Listener();
        //PruebasH tt = new PruebasH();
        //Hilo.setListenable(new PruebasH());
        //Hilo.start();
        
        //Hilo.finalize();
        
    }

    public static void ListDir(String path, ArrayList<String> dirs, String fileType)
    {
        String t = path;
        File f = new File(t);
        if(f.isDirectory())
        {
            String[] fn = f.list();
            for(int i=0; i< fn.length; i++)
            {
                t = path+"/"+fn[i];
                ListDir(t, dirs,fileType);
            }
        }
        else if(f.isFile())
        {
            if(path.substring(path.length()-fileType.length(), path.length()).equals(fileType))
                dirs.add(path);
        }
    }

    public static void writeShuffle(String filename, int Dir) throws FileNotFoundException, IOException
    {
        String[] part = filename.split("/");
        File file1 = new File(filename);

        //FileReader in = new FileReader(file1);
        InputStreamReader in = new InputStreamReader( new FileInputStream(file1), "UTF-8");


        String F = String.valueOf(Dir);
        if(F.length()==1)
            F="0"+F;
        
        String S_out = "HistogramsRnd/"+F;
        File mk = new File(S_out);
        if(!mk.exists())
            mk.mkdir();


        S_out = S_out+"/"+part[part.length-1];
        File file2 = new File(S_out);
        ///FileWriter out = new FileWriter(file2);
        PrintWriter out = new PrintWriter(file2, "UTF-8");
        int c;
        while ((c = in.read()) != -1)
        {
            out.write(c);
            //out.print(c);
        }
        
        out.close();
        in.close();


        
    }
    
}


